package com.xinyu.controller;


import com.xinyu.domain.Alarm;
import com.xinyu.domain.Daily;
import com.xinyu.service.IAlarmService;
import com.xinyu.vo.AlarmRequest;
import com.xinyu.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author l
 * @since 2025-02-20
 */
@RestController
@RequestMapping("/alarm")
public class AlarmController {

    @Autowired
    private IAlarmService alarmService;

    @PostMapping("/queryByCondition")
    public ResponseEntity<BaseResult> queryByCondition(@RequestBody AlarmRequest alarmRequest){
        BaseResult br = alarmService.queryByCondition(alarmRequest);
        return ResponseEntity.ok(br);
    }

    @PostMapping("/save")
    public ResponseEntity<BaseResult> saveDailyLogWithAttachment(@RequestBody Alarm alarm) {
        alarmService.save(alarm);
        return ResponseEntity.ok(BaseResult.ok());
    }


    @PostMapping("/update")
    public ResponseEntity<BaseResult> updateDailyLogWithAttachment(@RequestBody Alarm alarm) {

        boolean success = alarmService.updateById(alarm);
        return ResponseEntity.ok(BaseResult.ok());
    }

}

